package com.xln.demo9多态的应用综合;

public class Diaomaozhang {
    public void play(Game game) {
        if (game instanceof Duizhan) {

            Duizhan duizhan = (Duizhan) game;
            System.out.printf("掉毛张玩");
            duizhan.play();
            duizhan.xiabao();
        } else if (game instanceof Sangsi) {

            Sangsi sangsi = (Sangsi) game;
            System.out.printf("掉毛张玩");
            sangsi.play();
            sangsi.qiusheng();
        }
    }

    public Game selectgm(String youxi) {
        Game game = null;
        //==不能用于字符串的判断，只能用于数字或null的判断
        if (youxi.equals("1")) {
            game = new Duizhan();

        } else if (youxi.equals("2")) {
            game = new Sangsi();
        }
        return game;
    }

}
